//589.N叉树的前序遍历
//https://leetcode.cn/problems/n-ary-tree-preorder-traversal/
class Solution {
    vector<int> ret;
public:
    vector<int> preorder(Node* root) {
        dfs(root);
        return ret;
    }

    void dfs(Node* root)
    {
        if(root == nullptr) return;
        ret.push_back(root->val);
        for(Node* nd:root->children) if(nd) dfs(nd);
    }
};